import 'package:json_annotation/json_annotation.dart';
import 'package:xindong/models/chat_message/xindong_signal_message.dart';
import 'package:xindong/routes/call/controller/xindong_call_controller.dart';

part 'xindong_signal_class.g.dart';

@JsonSerializable()
class XinDongSignalClass {
  int? start; // 开始时间戳 秒
  int? end; // 结束时间戳 秒
  dynamic orderid;
  dynamic status;
  dynamic score;

  XinDongSignalClass();

  int get type {
    if (status == 0 && (end ?? 0) > 0) {
      return XinDongSignalActionType.end;
    } else if (status == XinDongActionStatus.accept && (end ?? 0) == 0) {
      return XinDongSignalActionType.accept;
    }
    return XinDongSignalActionType.cancel;
  }

  factory XinDongSignalClass.fromJson(Map<String, dynamic> json) => _$XinDongSignalClassFromJson(json);

  Map<String, dynamic> toJson() => _$XinDongSignalClassToJson(this);
}
